package com.wushi.lenovo.asia5b.app_ui.other.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.View;

import com.github.chrisbanes.photoview.PhotoView;
import com.mvp.base.BaseSimpleFragment;
import com.mvp.images.WImageLoader;
import com.wushi.lenovo.asia5b.R;
import com.wushi.lenovo.asia5b.app_config.CommonConstant;

import butterknife.BindView;

/**
 * Created by zhangyuncai on 2019/4/23.
 */
public class PhotoPreviewFragment extends BaseSimpleFragment {

    @BindView(R.id.photoview_photostore)
    PhotoView photoView;

    public static Fragment newInstance(Context context, String imgUrl) {
        Bundle bundle = new Bundle();
        bundle.putString(CommonConstant.PHOTO_PREVIEW_IMG, imgUrl);
        return Fragment.instantiate(context, PhotoPreviewFragment.class.getName(), bundle);
    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_photopreview;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        String imgUrl = getArguments().getString(CommonConstant.PHOTO_PREVIEW_IMG);
        if (!TextUtils.isEmpty(imgUrl)) {
            WImageLoader.displayImage(getContext(), imgUrl, photoView);
        }
    }

    @Override
    protected void lazyFetchData() {

    }
}
